package org.shagin.jfin.core.ui;

import javax.swing.JDialog;

/**
 * The Class JJDialog.
 */
@SuppressWarnings("serial")
public class JJDialog extends JDialog {
  
    public static final int MODAL_RESULT_NONE = 0;
    public static final int MODAL_RESULT_OK = 1;
    public static final int MODAL_RESULT_CANCEL = -1;

    private int modalResult = MODAL_RESULT_NONE;

    /**
     * Instantiates a new jJ dialog.
     */
    public JJDialog() {
        super();
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }

    /**
     * Show modal.
     * 
     * @return the int
     */
    public int showModal() {
        setModal(true);
        setVisible(true);
        return getModalResult();
    }

    /**
     * Gets the modal result.
     * 
     * @return the modal result
     */
    public int getModalResult() {
        return modalResult;
    }

    /**
     * Sets the modal result.
     * 
     * @param modalResult the new modal result
     */
    public void setModalResult(int modalResult) {
        this.modalResult = modalResult;
        setVisible(false);
    }

    /**
     * Close.
     */
    public void close() {
        setModalResult(MODAL_RESULT_NONE);
    }
}
